/*
	File:		EventSystem.h
	Author:		Ben Feldmann
	Purpose:	Handle events sent in the game
*/

#pragma once

#include <Windows.h>
using namespace std;

#include <list>
#include <map>
using std::list;
using std::multimap;
using std::pair;

//class Event;
//class IListener;
#include "Event.h"
#include "IListener.h"


class EventSystem 
{
private:
	list<Event> events;
	multimap<string, IListener*> clients;

	//static EventSystem* eventSystem;

	void DispatchEvent(Event* newEvent);
	bool AlreadyRegistered(string eventID, IListener* client);

	EventSystem() {}
	EventSystem(const EventSystem&);
	EventSystem& operator=(const EventSystem&);
	~EventSystem() {}

public:
	static EventSystem* GetInstance();

	void RegisterClient(string eventID, IListener* client);

	void UnregisterClientAll(IListener* client);

	void SendEvent(string eventID, void* data = nullptr, void* data2 = nullptr);

	void ProcessEvents();

	void ClearEvents();

	void ShutdownEventSystem();
};
